#!/bin/bash
# Word样式复制器安装脚本
# 作者: MiniMax Agent

echo "🔧 开始安装智能Word样式复制器..."

# 检查Python版本
python_version=$(python3 --version 2>&1 | grep -oP 'Python \K[0-9]+\.[0-9]+')
echo "检测到Python版本: $python_version"

# 安装依赖包
echo "📦 安装必要的Python包..."
pip3 install beautifulsoup4 lxml

# 检查并安装Pandoc
echo "🔍 检查Pandoc..."
if ! command -v pandoc &> /dev/null; then
    echo "⚠️  Pandoc未安装，请手动安装:"
    echo "  Ubuntu/Debian: sudo apt-get install pandoc"
    echo "  CentOS/RHEL: sudo yum install pandoc"
    echo "  macOS: brew install pandoc"
    echo "  或访问: https://pandoc.org/installing.html"
else
    echo "✅ Pandoc已安装: $(pandoc --version | head -1)"
fi

# 赋予执行权限
chmod +x /workspace/word_style_copier.py

echo "✅ 安装完成!"
echo ""
echo "使用方法:"
echo "1. 交互式模式: python3 word_style_copier.py --interactive"
echo "2. 抽取样式: python3 word_style_copier.py --extract source.docx"
echo "3. 应用样式: python3 word_style_copier.py --apply source.docx target.docx"
echo "4. 批量处理: python3 word_style_copier.py --batch-apply source.docx target1.docx target2.docx"
echo ""
echo "📖 详细使用说明请参考 README.md 文件"